package com.yijiaganxi.services.service.impl.banner;

import com.yijiaganxi.services.dao.banner.YjgxBannerMapper;
import com.yijiaganxi.services.service.banner.YjgxBannerService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.seata.core.context.RootContext;
import io.seata.tm.api.GlobalTransactionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yijiaganxi.common.entity.banner.YjgxBanner;

/**
 * <p>
 * 轮播管理 服务实现类
 * </p>
 *
 * @author zhangguowei123
 * @since 2020-08-29
 */
@Service
public class YjgxBannerServiceImpl extends ServiceImpl<YjgxBannerMapper, YjgxBanner> implements YjgxBannerService {

    @Autowired
    private YjgxBannerMapper bannerMapper;

    @Transactional
    @Override
    public Object test(YjgxBanner banner) {
        System.out.println("全局事物ID "+ GlobalTransactionContext.getCurrentOrCreate().getXid());
        System.out.println("全局事物ID "+ RootContext.getXID());
        Integer insert = bannerMapper.insert(banner);
        System.out.println(banner.getSort());
        if(banner.getSort()==2){
            System.out.println("2 进来了  要出错了");
            int a = 1/0;
        }
        return insert;
    }
}
